package com.bincloud.vue.admin.common.util;

import com.bincloud.vue.admin.common.model.entity.BaseEntity;

import java.time.LocalDateTime;

/**
 * @Description: 基类实体工具类
 * @Author: bincloud, mvpzhou
 * @Date: Create By bincloud, mvpzhou on 2022/2/19
 */
@SuppressWarnings("unused")
public class BaseEntityUtils {

    private BaseEntityUtils(){}

    public static <T extends BaseEntity> void create(T entity, String username) {
        LocalDateTime now = LocalDateTime.now();
        entity.setCreateBy(username);
        entity.setCreateTime(now);
        entity.setModifyBy(username);
        entity.setModifyTime(now);
    }

    public static <T extends BaseEntity> void modify(T entity, String username) {
        entity.setModifyBy(username);
        entity.setModifyTime(LocalDateTime.now());
    }
}
